package com.tanyu.drawing;

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.File;
import javax.imageio.ImageIO;

/**
 * @Author Tanyu
 * @Date 2020/6/5 16:34
 * @Description
 * @Version 1.0
 */
public class TheComputerScreen {

  public static void main(String[] args) throws Exception {
    // 获取屏幕尺寸
    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    // 创建需要截取的矩形区域
    Rectangle rectangle = new Rectangle(0, 0, dimension.width, dimension.height);
    // 截屏操作
    BufferedImage bufferedImage = new Robot().createScreenCapture(rectangle);
    // 保存截取的图片
    ImageIO.write(bufferedImage, "PNG", new File("C:/test/captutr.png"));
  }
}
